local talan = fk.CreateSkill{
  name = "mini__talan",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["mini__talan"] = "踏澜",
  [":mini__talan"] = "锁定技，你使用于出牌阶段从牌堆获得的牌无次数限制且不计入次数。",

  ["@@mini__talan-inhand"] = "踏澜",

  ["$mini__talan1"] = "当铸安澜之功，以复汉室之荣。",
  ["$mini__talan2"] = "云志在平世，何惧瀚海惊澜？",
}

talan:addEffect(fk.AfterCardsMove, {
  can_refresh = function (self, event, target, player, data)
    return player:hasSkill(talan.name) and player.phase == Player.Play
  end,
  on_refresh = function (self, event, target, player, data)
    local cards = {}
    for _, move in ipairs(data) do
      if move.to == player and move.toArea == Card.PlayerHand then
        table.insertTable(cards, table.map(move.moveInfo, function(info) return info.cardId end))
      end
    end
    table.forEach(cards, function(id)
      player.room:addCardMark(Fk:getCardById(id), "@@mini__talan-inhand")
    end)
  end
})

talan:addEffect("targetmod", {
  bypass_times = function (self, player, skill, scope, card, to)
    return card and player:hasSkill(talan.name) and card:getMark("@@mini__talan-inhand") > 0
  end,
})

talan:addEffect(fk.PreCardUse, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(talan.name) and
      table.every(Card:getIdList(data.card), function(id) return Fk:getCardById(id):getMark("@@mini__talan-inhand") > 0 end)
  end,
  on_use = function(self, event, target, player, data)
    data.extraUse = true
  end,
})

return talan
